#pragma once
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string>
#include <cstring>

const int MAXBUFSIZE = 1024;
class client
{
public:
    client()
    {
        _sock_fd = socket(AF_INET,SOCK_DGRAM,0);
        if(_sock_fd < 0)
        {
            std::cerr<<"socket error"<<std::endl;
            exit(1);
        }
        
    }
    void SendTo(const sockaddr_in& server_addr, const std::string& msg)
    {
        int ret = sendto(_sock_fd, msg.c_str(), msg.size(), 0, (sockaddr*)&server_addr, sizeof(server_addr));
        if(ret < 0)
        {
            std::cerr<<"sendto error"<<std::endl;
            exit(2);
        }
    }
private:
    int _sock_fd;
};